import QtQuick 1.0

Item {
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.margins: 10
    property bool animOnLeft: true
    width: parent.width
    property string buttonText
    height: childrenRect.height
    signal buttonClicked;

    Row {
        spacing: 10
        width: parent.width
        anchors.horizontalCenter: parent.horizontalCenter
        Text {
            visible: !animOnLeft
            text: buttonText
            anchors.verticalCenter: parent.verticalCenter
            font.family: throwHands.name
            font.pointSize: 12
        }

        Image {
            id: spinner
            source: "assets/spinner.png"
            width: 100
            height: 100
            transformOrigin: {Item.Center}

            RotationAnimation on rotation {
                duration: 5000
                direction: RotationAnimation.Clockwise
                running: true
                loops: Animation.Infinite
                from: 0
                to: 360
                alwaysRunToEnd: true
            }
        }

        Text {
            visible: animOnLeft
            text: buttonText
            anchors.verticalCenter: parent.verticalCenter
            font.family: throwHands.name
            font.pointSize: 12
        }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            buttonClicked();
        }
    }
}
